// HuaweiNetwork.h: interface for the HuaweiNetwork class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HUAWEINETWORK_H__0612B582_B2C6_4682_AAB5_0004AB887CFA__INCLUDED_)
#define AFX_HUAWEINETWORK_H__0612B582_B2C6_4682_AAB5_0004AB887CFA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>
#include "global.h"
#include <pcap.h>
using namespace std;
#define WM_INFO			WM_USER+1
#define WM_INTERRUPTED	WM_USER+2
extern "C"
{
//  void GetInterfaceMac(string interface, int *mac);
  int	pcap_sendpacket(pcap_t *, const u_char *, int);
}

  
// int GetSystemInterfaceInfo(InterfaceInfo * infoarray);	

class HuaweiNetwork
{
  u_char  m_DestMac[6];
  pcap_t *m_fp;
  USERDATA m_Data;
  bool isonline;
  HWND hWnd;
		
  // signals:
  //  void Message(const QString & );	
  void Connected();
  void ConnectionInterrupted();
			
 protected:
  char m_ClientVersion[14];
  bool SendVersion(const u_char Id);
  bool SendUsername(const u_char Id);
  bool SendPassword(const u_char Id, const u_char *Chap);
  bool SendKeeponline(const u_char Id);
			
  bool OpenAdapter();
  void CloseAdapter();
			
  void SetMd5Buf(PPASSWORDFRM pBuf, const u_char ID, const u_char *chap);
  void InitBuf(u_char *buf);
		
  bool SendLogin();
  bool SendLogout();

  void run();
  void GenerateVersion(u_char *buf);
  void EncodeVersion(char *strConst,unsigned char *strDest,int iSize);
 public:
  HuaweiNetwork(HWND hWnd,const string & username,const string & passwd,const string & interfacenum, int * ip, int *mac,const string& version="2.40-0145");
  virtual ~HuaweiNetwork();
	
  /*$PROTECTED_FUNCTIONS$*/
	 
		
  void Connect();
  void DisConnect();		
};

#endif // !defined(AFX_HUAWEINETWORK_H__0612B582_B2C6_4682_AAB5_0004AB887CFA__INCLUDED_)
